﻿using Socium.Domain.Tests;
using Socium.Presentation;

namespace Socium.TestEditor {
	class VariantViewModel : FormViewModel<Variant> {
		public VariantViewModel() {}
		public VariantViewModel(Variant model) : base(model) {}

		string _text;
		public string Text {
			get { return _text; }
			set {
				_text = value;
				OnPropertyChanged("Text");
			}
		}

		protected override void Save(Variant model) {
			model.Text = _text;
		}

		protected override string GetDisplayName(Variant model) {
			return model.Text;
		}

		protected override string GetDefaultDisplayName() {
			return "New variant";
		}

		protected override Variant CreateModel() {
			return new Variant(_text);
		}

		protected override void Update(Variant model) {
			Text = model.Text;
		}

		public override bool CanSave() {
			return !string.IsNullOrWhiteSpace(_text);
		}
	}
}
